package com.whut.coc.exception;

import com.whut.coc.enums.ResultCode;
import lombok.Getter;

public class BusinessException extends RuntimeException {

    private final String message;

    @Getter
    private Integer code = 500;

    public BusinessException(String message) {
        super(message);
        this.message = message;
    }

    public BusinessException(Integer code, String message) {
        super(message);
        this.message = message;
        this.code = code;
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
        this.message = message;
    }

    public BusinessException(Integer code, String message, Throwable cause) {
        super(cause);
        this.message = message;
        this.code = code;
    }

    public BusinessException(ResultCode resultCode) {
        this.message = resultCode.getMessage();
        this.code = resultCode.getCode();

    }

    @Override
    public String getMessage() {
        return message;
    }
}
